import { IFeidaoAiMobile } from '@dfeidao/atom-mobile/interfaces';
import set from '@dfeidao/atom-mobile/local/set';
import nodejs from '@dfeidao/atom-mobile/msg/nodejs';
import get_param from '@dfeidao/atom-mobile/nav/get-param';
import render from '@dfeidao/atom-mobile/render/render';
import { file_url, productid } from '../atom/config';
import whoami from '../atom/whoami_getparams';

export default async function a001(fd: IFeidaoAiMobile) {
	// init
	const p = await whoami(fd) as { userinfo: { productid: string; } };
	if (!p.userinfo.productid) {
		console.log('请先登录！');
		return;
	}
	const student_no = get_param(fd, 'student_no');
	const d = await nodejs<{ faceid: string; }>('app-replac-photo/s001', { query: { student_no } });
	const headimg = d.faceid ? file_url + `/getfile?productid=${productid}&id=${d.faceid}` : '';
	render(fd, { student_no, headimg, loading: '1' });
	set(fd, 'd', { productid: p.userinfo.productid, student_no, headimg });
}
